home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / ReaderMouse / UtilityFunctions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-23  |  986 b   |  38 lines  |  [TEXT/CWIE]

  1.  
  2. #ifndef _UTILITYFUNCTIONS_
  3. #define _UTILITYFUNCTIONS_
  4.  
  5. #ifdef __cplusplus
  6. extern "C"
  7. {
  8. #endif
  9.  
  10. /* Macros */
  11. #define MAX(x,y)((x)<(y)?(y):(x))
  12. #define MIN(x,y)((x)<(y)?(x):(y))
  13. #define ABS(x)((x)<0?(-1*(x)):(x))
  14.  
  15. #define RECT_EQUAL(a,b) {a.top = b.top; a.left=b.left; a.right=b.right; a.bottom=b.bottom;}
  16.  
  17.  
  18. /* prototypes */
  19.  
  20. /* returns a floating point between lowBound and highBound with uniform distribution. */
  21. float    UtilRandomFloat (float lowBound, float highBound);
  22. long    UtilRandomLong (long lowBound, long highBound);
  23.  
  24. /* if seed is 0, initializes to time, otherwise sets to that seed */
  25. void    UtilSeedRandom (long seed);
  26.  
  27. float    UtilEuclideanDistance (float x1, float y1, float x2, float y2);
  28. void    NormalizeVector (float *x, float *y);
  29.  
  30. /* solves the Least Squares approximation to a linear fit of a set of points */
  31. void UtilLeastSquareLineApprox (float *x, float *y, long numPoints, float *slope, float *yIntercept);
  32.  
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36.  
  37.  
  38. #endif /* _UTILITYFUNCTIONS_ */